package com.balance.anole.erp.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;


public class ServicesCenter implements BeanFactoryAware{

    private static BeanFactory beanFactory = null;

    private static ServicesCenter serviceCenter = null;

	public static ServicesCenter getServicesCenter(){
		if(serviceCenter == null){
			serviceCenter = (ServicesCenter) beanFactory.getBean("serviceCenter");
		}
		return serviceCenter;
	}

	public Object getService(String interfaceName){
		return beanFactory.getBean(interfaceName);
	}

	public <T> T getService(Class<T> className){
		return (T) beanFactory.getBean(className.getName());
	}

	@Override
	public void setBeanFactory(BeanFactory arg0) throws BeansException {
		beanFactory = arg0;
	}

}
